/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * leafget
 * Copyright (C) xinliGG 2008 <xinliGG@gmail.com>
 * 
 * leafget is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * leafget is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _SOCKET_H_
#define _SOCKET_H_
 
#include <string>
#include <arpa/inet.h>
 
class Socket
{
public:
	Socket();
	virtual ~Socket();			
			
			
		/* intial functions */

	const bool create  ( void );
	const bool connect ( const std::string host, const int port );
	const bool close   ( void );

		/* data functions */
		
	const bool send             ( const std::string ) const;
	const int  recv             ( char *, const int ) const;
	void       set_non_blocking ( const bool );

		/* get functions */
	
	const int get_sock ( void ) const;
	
		/* check functions */

	const bool is_valid ( void ) const;
	
protected:

private:
	int         sock;
	sockaddr_in addr;
};

#endif // _SOCKET_H_
